#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL n, x;
LL a[N];
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> x >> n;
		memset(a, 0, sizeof(a));
		bool flag = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			if (a[i] > x) {
				flag = 1;
			}
		}
		if (n >= x || x <= 0) { 
			cout << 0 << endl;
			continue;	
		}
		if (n < 0)n = 0;
		LL ans1 = (x - n) * 5;
		LL ans2 = 0;
		LL temp = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i] > x)continue;
			ans2 += (a[i] - temp - 1) / 7;
			temp = a[i];
		}
		ans2 += (x - a[n]) / 7;
		//cout << "ans1==" << ans1 << endl;
		//cout << "ans2==" << ans2 << endl;
		cout << ans1 - ans2 * 50 << endl;
	}
	return 0;
}

//1 2 3 4 5 6 7 8 9 10